<?php 
	class Page{
		private $total = NULL;
		private $pagesize = NULL;
		private $pagename=NULL;
		public function  __construct($total,$pagesize,$pagename = "pageno"){
			$this->total=$total;
			$this->pagesize=$pagesize;
			$this->pagename=$pagename;
		}
		public function show(){
			$left=2;
			$pageno = isset($_GET["{$this->pagename}"])?trim($_GET["{$this->pagename}"]):1;
			if ( $pageno<1 ) {
				$pageno=1;
			}
			$pageNum = ceil($this->total/$this->pagesize);
			$html = '<div class="ui-page-box">';
			$html.= '<a class="ui-title">总记录:'.$this->total.'</a>';
			$html.= '<a class="ui-title">'.$pageno.'/'.$pageNum.'</a>';
			if ($pageno==1) {
				$html.= '<a class="ui-unable">首页</a>';
				$html.= '<a class="ui-unable"><<上一页</a>';
			}else{
				$html.= '<a href="?'.$this->pagename.'=1 " class="ui-able">首页</a>';

				$html.= '<a href="?'.$this->pagename.'='.($pageno-1).' " class="ui-able"><<上一页</a>';
			}
			$start = $pageno-$left;
			if ($start<=0) {
				$start=1;
			}
			for ($i=$start; $i < $pageno; $i++) { 
					$html.= '<a href="?'.$this->pagename.'='.$i.' " class="ui-able">'.$i.'</a>';
			}
			$html.= '<a class="ui-unable">'.$pageno.'</a>';
			$end = $pageno+$left;
			if ($end>$pageNum) {
				$end=$pageNum;
			}
			for ($i=$pageno+1; $i <=$end; $i++) { 
					$html.= '<a href="?'.$this->pagename.'='.$i.' " class="ui-able">'.$i.'</a>';
			}
			if ($pageno==$pageNum) {
				$html.=' <a class="ui-unable">下一页>></a>';
				$html.=' <a class="ui-unable">尾页</a>';
			}else{
				$html.=' <a href="?'.$this->pagename.'='.($pageno+1).' " class="ui-able">下一页>></a>';
				$html.=' <a href="?'.$this->pagename.'='.$pageNum.' " class="ui-able">尾页</a>';
			}
			$html.= '</div>';
			return $html;
		}
		public function getoffset(){
			echo "6666";
		}
	}
	$Page = new Page(101,10);
	$html=$Page ->show();
 ?>

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
 <head>
 	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
 	<title>分页类</title>
 	<style type="text/css">
 		*,body{
 			margin:0px;
 			padding: 0px;
 		}
 		.ui-page-box{
 			overflow: hidden;
 		}
		.ui-page-box a{
			display: inline-block;
			border:1px solid #ccc;
			font-size: 12px;
			height: 26px;
			line-height: 26px;
			padding: 0px 10px;
			float: left;
			text-decoration: none;
		}
		.ui-unable{
			background: #efefef;
			color:#999;
		}
		.ui-able{
			color:blue;
		}
		.ui-title{
			color:#999;
		}
 	</style>
 </head>
 <body>
 	<div style="width:100%;text-align:center;margin-left:100px;margin-top:100px">
		<?php echo $html; ?>
 	</div>
 </body>
 </html>